package utils;
import java.util.*;
public class UserInfo {
	public int userId;
	public Map<Integer, Interaction> interactions;
	//List<Interaction> newInteractions;
	public UserInfo(String id)	{
		userId = new Integer(id);
		interactions = new TreeMap<Integer,Interaction>();
	}
	public void addInteraction(String userIdB,String actionType)	{
		Interaction interaction = interactions.get(new Integer(userIdB));
		boolean needAdd = false;
		if(interaction == null){
			interaction = new Interaction();
			interaction.userId = new Integer(userIdB);
			needAdd = true;
		}
		
		if(actionType.equals( "rec"))				
			interaction.recCount ++;
		else if(actionType.equals("click"))
			interaction.clickCount ++;
		else if(actionType.equals("msg"))
			interaction.msgCount ++;
		else {
			assert false : "wrong action type";
			System.out.println(actionType);
		}
	
		if(needAdd){
			interactions.put(new Integer(userIdB), interaction);
		}
	}
	public static  Comparator getComparator()	{
		return new UserInfoComparator();
	}
	/*
	private Interaction getInteractionOfUserB(int id)	{
		
		for(int i = 0; i < newInteractions.size();i++)	{
			if(newInteractions.get(i).userId == id)
				return newInteractions.get(i);
		}
		return null;
	}*/

	
}
class UserInfoComparator implements Comparator<UserInfo>	{

	@Override
	public int compare(UserInfo u1, UserInfo u2) {
		
		return u1.userId - u2.userId;
	}
	
};

